home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / src / Fl_Value_Slider.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-14  |  2.3 KB  |  77 lines

  1. //
  2. // "$Id: Fl_Value_Slider.cxx,v 1.5.2.1 1999/05/14 09:07:08 bill Exp $"
  3. //
  4. // Value slider widget for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <FL/Fl.H>
  27. #include <FL/Fl_Value_Slider.H>
  28. #include <FL/fl_draw.H>
  29. #include <math.h>
  30.  
  31. Fl_Value_Slider::Fl_Value_Slider(int x,int y,int w,int h, const char*l)
  32. : Fl_Slider(x,y,w,h,l) {
  33.   step(1,100);
  34.   textfont_ = FL_HELVETICA;
  35.   textsize_ = 10;
  36.   textcolor_ = FL_BLACK;
  37. }
  38.  
  39. void Fl_Value_Slider::draw() {
  40.   int sxx = x(), syy = y(), sww = w(), shh = h();
  41.   int bxx = x(), byy = y(), bww = w(), bhh = h();
  42.   if (horizontal()) {
  43.     bww = 35; sxx += 35; sww -= 35;
  44.   } else {
  45.     syy += 25; bhh = 25; shh -= 25;
  46.   }
  47.   if (damage()&FL_DAMAGE_ALL) draw_box(box(),sxx,syy,sww,shh,color());
  48.   Fl_Slider::draw(sxx+Fl::box_dx(box()),
  49.           syy+Fl::box_dy(box()),
  50.           sww-Fl::box_dw(box()),
  51.           shh-Fl::box_dh(box()));
  52.   draw_box(box(),bxx,byy,bww,bhh,color());
  53.   char buf[128];
  54.   format(buf);
  55.   fl_font(textfont(), textsize());
  56.   fl_color(active_r() ? textcolor() : inactive(textcolor()));
  57.   fl_draw(buf, bxx, byy, bww, bhh, FL_ALIGN_CLIP);
  58. }
  59.  
  60. int Fl_Value_Slider::handle(int event) {
  61.   int sxx = x(), syy = y(), sww = w(), shh = h();
  62.   if (horizontal()) {
  63.     sxx += 35; sww -= 35;
  64.   } else {
  65.     syy += 25; shh -= 25;
  66.   }
  67.   return Fl_Slider::handle(event,
  68.                sxx+Fl::box_dx(box()),
  69.                syy+Fl::box_dy(box()),
  70.                sww-Fl::box_dw(box()),
  71.                shh-Fl::box_dh(box()));
  72. }
  73.  
  74. //
  75. // End of "$Id: Fl_Value_Slider.cxx,v 1.5.2.1 1999/05/14 09:07:08 bill Exp $".
  76. //
  77.